package com.xrkj.b2c.controller.sys;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xrkj.b2c.controller.common.BasicController;
import com.xrkj.b2c.model.sys.SysSupplier;
import com.xrkj.b2c.service.sys.SysSupplierService;
import com.xrkj.b2c.utils.StringUtil;

/**
 * 
 * <B>系统名称：</B><BR>
 * <B>模块名称：</B><BR>
 * <B>中文类名：</B>供应商控制器<BR>
 * <B>概要说明：</B><BR>
 * @author 赵子靖
 * @since 2018年7月14日
 */
@RequestMapping("/sysSupplier")
@Controller
public class SysSupplierController extends BasicController {
    
    @Autowired
    protected SysSupplierService supplierService;
    
	private Logger logger=Logger.getLogger(SysSupplierController.class);
    
	/**
	 * 
	 * <B>方法名称：</B>加载供应商列表<BR>
	 * <B>概要说明：</B><BR>
	 * @author perry
	 * @since 2018年7月14日 	
	 * @param request
	 * @param response
	 * @return
	 */
    @RequestMapping("/getSupplierList")
    @ResponseBody
    public Object getSupplierList(HttpServletRequest request, HttpServletResponse response) {
        String search = request.getParameter("search");//名称
        String offset = request.getParameter("offset");
        String limit = request.getParameter("limit");
        Map<String, Object> ret = new HashMap<String, Object>();
        Map<String, Object> paramter = new HashMap<String, Object>();
        paramter.put("offset", StringUtil.isEmpty(offset) ? null : Integer.parseInt(offset));
        paramter.put("limit", StringUtil.isEmpty(limit) ? null : Integer.parseInt(limit));
        paramter.put("search", search);
        Integer total = supplierService.findSupplierTotal(paramter);
        List<SysSupplier> menus = new ArrayList<SysSupplier>();
        if (total > 0) {
            menus = supplierService.findSupplierList(paramter);
        }
        ret.put("total", total);
        ret.put("rows", menus);
        return ret;
    }
    
    
}
